package org.ciallo.simplemusicplayer.data.model;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;

/**
 * @author Jukomu
 * @Description: 代表最近播放歌曲的实体
 * @Package: org.ciallo.simplemusicplayer.data.model
 * @Project: SimpleMusicPlayer
 * @name: PlaylistSongCrossRef
 * @Date: 2025/5/30-00:58
 * @Filename: PlaylistSongCrossRef
 */
@Entity(tableName = "recently_played_songs",
        foreignKeys = @ForeignKey(entity = Song.class,
                parentColumns = "id",
                childColumns = "song_id",
                onDelete = ForeignKey.CASCADE)) // 如果Song被删除，其播放记录也删除
public class RecentlyPlayedSong {

    /**
     * 播放的歌曲ID，作为主键。
     * 关联到 Song 表中的歌曲ID。
     */
    @PrimaryKey
    @ColumnInfo(name = "song_id")
    public long songId;

    /**
     * 歌曲最后一次被播放的时间戳 (毫秒)。
     * 用于排序，最新的在最前面。
     */
    @ColumnInfo(name = "last_played_timestamp")
    public long lastPlayedTimestamp;

    public RecentlyPlayedSong(long songId, long lastPlayedTimestamp) {
        this.songId = songId;
        this.lastPlayedTimestamp = lastPlayedTimestamp;
    }
}
